window.$config = {
    host: '',
    // host: '',
    rex: {
        tel: /^1[34578]\d{9}$/
    },
    // 滚动到顶部
    toTop: function (func) {
        var timer = setInterval(function () {
            //获取滚动条距离顶部高度
            var osTop = document.documentElement.scrollTop || document.body.scrollTop;
            var ispeed = Math.floor(-osTop / 7);

            document.documentElement.scrollTop = document.body.scrollTop = osTop + ispeed;
            //到达顶部，清除定时器
            if (osTop == 0) {
                clearInterval(timer);
                if (func) {
                    func();
                }
            }
            ;
        }, 30);
    },
    iswx: function () {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger') {
            return true;
        } else {
            return false;
        }
    },
    wxShare: function () {
        var time = setInterval(function () {
            try {
                if (!wx || !oe_wxconfig) return;
            } catch (e) {
            }

            clearTimeout(time);
            var config = oe_wxconfig,
                title = "寻找最美合伙人",
                summary = "网剧主角和百万创投基金虚位以待",
                link = "http://h5.oeeee.com/h5/zmhhr",
                thumb = "http://h5.oeeee.com/h5/zmhhr/logo.jpg",
                content = {
                    title: title,
                    desc: summary,
                    link: link,
                    imgUrl: thumb,
                    type: '',
                    dataUrl: '',
                    success: function () {
                    },
                    cancel: function () {
                    }
                }

            wx.config({
                debug: false,
                appId: config.appId,
                timestamp: config.timestamp,
                nonceStr: config.nonceStr,
                signature: config.signature,
                jsApiList: [
                    'onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareWeibo'
                ]
            });
            wx.checkJsApi({
                jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareWeibo'],
                success: function (res) {
                }
            });
            wx.ready(function () {
                wx.onMenuShareAppMessage(content);
                wx.onMenuShareTimeline(content);
                wx.onMenuShareQQ(content);
                wx.onMenuShareWeibo(content);
            });
        }, 500);
    },
    playMusic: function(){
        var audio = document.getElementById('bgmusic');
        function audioAutoPlay(){
            audio.play();
            document.addEventListener("WeixinJSBridgeReady", function () {
                audio.play();
            }, false);
            document.addEventListener('YixinJSBridgeReady', function() {
                audio.play();
            }, false);
        }

        $('.music').click(function(){
            if(audio!==null) {
                if(audio.paused){
                    audio.play();
                    $('.music').addClass('on');
                }else{
                    audio.pause();
                    $('.music').removeClass('on');
                }
            }
        });

        audioAutoPlay();
    },
    init: function () {
        if (this.iswx()) {
            var jwx1 = document.createElement('script');
            jwx1.setAttribute('src', 'http://res.wx.qq.com/open/js/jweixin-1.0.0.js');
            document.body.appendChild(jwx1);
            var jwx2 = document.createElement('script');
            jwx2.setAttribute('src', 'https://m.mp.oeeee.com/helper.php?m=WxHelper&a=config&domain=oeeee.com');
            document.body.appendChild(jwx2);

            this.wxShare();
        }
        this.playMusic();
    },
    geoCoordMap: [{"name": "广州", "value": [113.486215, 23.322341]}, {
        "name": "韶关",
        "value": [113.591544, 24.801322]
    }, {"name": "深圳", "value": [114.085947, 22.547]}, {"name": "珠海", "value": [113.295584,22.213626]}, {
        "name": "汕头",
        "value": [116.658014, 23.293636]
    }, {"name": "佛山", "value": [113.022394, 23.029959]}, {
        "name": "江门",
        "value": [112.781326, 22.316272]
    }, {"name": "湛江", "value": [110.364977, 21.274898]}, {
        "name": "茂名",
        "value": [110.914163, 22.028946]
    }, {"name": "肇庆", "value": [112.123483, 23.52947]}, {"name": "惠州", "value": [114.412599, 23.079404]}, {
        "name": "梅州",
        "value": [116.117582, 24.299112]
    }, {"name": "汕尾", "value": [115.472969, 22.951778]}, {
        "name": "河源",
        "value": [114.883302, 24.014875]
    }, {"name": "阳江", "value": [111.975107, 21.859222]}, {
        "name": "清远",
        "value": [112.873722, 24.256594]
    }, {"name": "东莞", "value": [113.82136, 22.991421]}, {"name": "中山", "value": [113.382391, 22.521113]}, {
        "name": "潮州",
        "value": [116.861405, 23.802694]
    }, {"name": "揭阳", "value": [116.137768, 23.253106]}, {"name": "云浮", "value": [112.044439, 22.929801]}]
}
$config.init();